Package cpsc2150.extendedConnectX.models
Class BoardPosition
java.lang.Object
cpsc2150.extendedConnectX.models.BoardPosition
Keep track of an individual cell for a board.
This class keeps row and column information for a single cell on the game board and provides methods to get the row and column numbers.
- Invariant:
- 0
>=row<IGameBoard.MAX_ROWS AND 0>=column<IGameBoard.MAX_COLUMNS
-
Constructor Summary
ConstructorsConstructorDescriptionBoardPosition(int Row, int Column) Constructor for BoardPosition that takes integers for row and column. -
Method Summary
-
Constructor Details
-
BoardPosition
public BoardPosition(int Row, int Column) Constructor for BoardPosition that takes integers for row and column.- Parameters:
Row- number corresponding to rowColumn- number corresponding to column- Pre:
- 0
>=Row<IGameBoard.MAX_ROWS AND 0>=IGameBoard.Column<MAX_COLUMNS - Post:
- row = Row AND column = Column
-
-
Method Details
-
equals
Overloaded equals method for BoardPosition.- Overrides:
equalsin classObject- Parameters:
o- Object to check if equal to- Returns:
- Whether two BoardPosition objects are equal
- Post:
- equals = true iff ((BoardPosition) o = this) AND row = #row AND column = #column equals = false iff ((BoardPosition) o != this) AND row = #row AND column = #column
-
toString
Overloaded toString method for BoardPosition.NOTE: The string will change depending on the values of the BoardPosition object that calls the toString method, and thus the post-condition for this method is partially informal.
-
getRow
public int getRow()This function returns the value of the row number.- Returns:
- The row value
- Post:
- getRow = row AND row = #row AND column = #column
-
getColumn
public int getColumn()This function returns the value of the column number.- Returns:
- The column value
- Post:
- getColumn = column AND row = #row AND column = #column
-